Passed
Push — master ( d888e7...d5d975 )
by Rafael
01:12
created

webpack.prod.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
nc 1
dl 0
loc 3
rs 10
cc 1
nop 1
1
const path = require( 'path' );
2
const webpack = require( 'webpack' );
3
const HtmlWebpackPlugin = require( 'html-webpack-plugin' );
4
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
5
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
6
const MinifyPlugin = require( 'babel-minify-webpack-plugin' );
7
8
const srcDir = path.resolve( __dirname, '..', 'src' );
9
const distDir = path.resolve( __dirname, '..', 'dist' );
10
11
module.exports = {
12
	context: srcDir,
13
14
	devtool: false,
15
16
	entry: {
17
		application: './index.js',
18
		bundle: './controls/index.js'
19
	},
20
21
	output: {
22
		filename: '[name].min.js',
23
		path: distDir,
24
		publicPath: '/',
25
		sourceMapFilename: '[name].map'
26
	},
27
28
	module: {
29
		rules: [
30
			{
31
				test: /\.html$/,
32
				use: [
33
					{
34
						loader: 'html-loader',
35
						options: {
36
							minimize: true
37
						}
38
					}
39
				]
40
			},
41
			{
42
				test: /\.js$/,
43
				use: [ 'babel-loader' ],
44
				include: [
45
					srcDir
46
				]
47
			},
48
			{
49
				test: /\.js$/,
50
				enforce: 'pre',
51
				exclude: /node_modules/,
52
				loader: 'eslint-loader',
53
				options: {
54
					emitWarning: true
55
				}
56
			},
57
			{
58
				test: /\.(scss|css)$/,
59
				use: ExtractTextPlugin.extract( {
60
					fallback: 'style-loader',
61
					use: [
62
						{
63
							loader: 'css-loader',
64
							options: {
65
								minimize: true
66
							}
67
						},
68
						{
69
							loader: 'sass-loader',
70
							options: {
71
								includePaths: [ 'node_modules' ]
72
							}
73
						},
74
						{
75
							loader: 'postcss-loader',
76
							options: {
77
								plugins: ( loader ) => [
0 ignored issues
show
Unused Code introduced by
The parameter loader is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
78
									require( 'autoprefixer' )()
79
								]
80
							}
81
						}
82
					]
83
				} )
84
			},
85
			{
86
				test: /\.(jpg|jpeg|png|gif|ico|svg)$/,
87
				loader: 'url-loader',
88
				query: {
89
					limit: 10000, // Use data url for assets <= 10KB
90
					name: './[name].[hash].[ext]'
91
				}
92
			}
93
		]
94
	},
95
96
	plugins: [
97
		new CopyWebpackPlugin( [
98
			{
99
				from: './../static',
100
				to: ''
101
			},
102
			{
103
				from: require.resolve( 'Iris/dist/iris.min.js' ),
104
				to: './static'
105
			},
106
			{
107
				from: require.resolve( 'sass.js/dist/sass.worker.js' ),
108
				to: './static'
109
			},
110
			{
111
				from: path.resolve( require.resolve( 'Buttons/scss/buttons.scss' ), '..' ),
112
				to: './scss/color-palette-scss/buttons'
113
			},
114
			{
115
				from: srcDir + '/controls/color/scss/utilities/color-classes.sass',
116
				to: './scss/color-palette-scss/classes/color-classes.scss'
117
			}
118
		] ),
119
120
		new MinifyPlugin(),
121
122
		new webpack.NamedModulesPlugin(),
123
124
		new HtmlWebpackPlugin( {
125
			template: path.join( srcDir, 'index.ejs' ),
126
			path: distDir,
127
			filename: 'index.html',
128
			hash: true,
129
			minify: {
130
				removeComments: true,
131
				minifyJS: true,
132
				minifyCSS: true,
133
				collapseWhitespace: true
134
			}
135
		} ),
136
137
		new ExtractTextPlugin( '[name].min.css' )
138
	]
139
};
140